import axios from "axios";
import { ElLoading } from 'element-plus'
var loadingInstance;
const initAxios = axios.create({
    timeout: 1800000 //数据响应过期时间
})

//请求拦截器
initAxios.interceptors.request.use((config) => {
    //在发送之前做点什么
    loadingInstance = ElLoading.service({ fullscreen: true, background: 'rgba(0, 0, 0, 0.2)' })
    return config
}, (error) => {
    //对请求错误做点什么
    return error
})

//响应拦截器
initAxios.interceptors.response.use((response) => {
        loadingInstance.close()
        return response.data
    })
    //导出
export default () => initAxios